using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using FutureOpen.Web.Pages;
using FutureOpen.Core.func;
using FutureOpen.Core;
using FutureOpen.Core.func.db;

public partial class test_OrgSelect : PageBase
{
    private int cat;
    private string prefix;
    private MyOrg myorg = new MyOrg();    
    protected void Page_Load(object sender, EventArgs e)
    {
        this.PageInit();
        LoadMyParams();

        if (!Page.IsPostBack)
        {
            AspNetPager1.RecordCount = myorg.GetAllOrgCount(cat, prefix);
            BindOrgs(0, 10); 
        }        
    }

    private void BindOrgs(int start, int count)
    {
        //int count = myorg.GetAllOrgCount(cat, prefix);
      
        IList<Org> orgList = myorg.GetOrgList(start, count, cat, prefix);

        GridView1.DataSource = orgList;
        GridView1.DataBind();
            
    }
    private void LoadMyParams()
    {
        string temp = Request.QueryString["c"];
        if (!string.IsNullOrEmpty(temp))
        {
            cat = Int32.Parse(temp);
        }
        else
        {
            cat = -1;
        }

        temp = Request.QueryString["p"];
        prefix = temp; 
    }


    protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        AspNetPager1.CurrentPageIndex = e.NewPageIndex;
        BindOrgs((AspNetPager1.CurrentPageIndex - 1) * 10, 10);
    }
}
